// Package repository
// Created by GoLand
// @User: lenora
// @Date: 2023/12/12
// @Time: 14:53

package repository

import (
	"camp/microbook/internal/repository/cache"
	"context"
)

var ErrSendTooMany = cache.ErrSendTooMany

type CodeRepository interface {
	Set(ctx context.Context, biz, phone, code string) error
	Verify(ctx context.Context, biz, phone, code string) error
}

type codeRepository struct {
	cache cache.CodeCache
}

func NewCodeRepository(codeCache cache.CodeCache) CodeRepository {
	return &codeRepository{
		cache: codeCache,
	}
}

func (c *codeRepository) Set(ctx context.Context, biz, phone, code string) error {
	return c.cache.Set(ctx, biz, phone, code)
}

func (c *codeRepository) Verify(ctx context.Context, biz, phone, code string) error {
	return c.cache.Verify(ctx, biz, phone, code)
}
